package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.feign.WxMiniHomeClient;
import com.sc.nft.req.home.HomePageReq;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.home.HomePageDetailsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/wxMiniMall/home")
@Api(tags = "小程序主页")
public class WxMiniHomeController{

    private final WxMiniHomeClient wxMiniHomeClient;

    /**
     * 小程序主页创建
     * @param request
     * @return
     */
    @PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "创建主页")
    @SysMemberLogin
    public Result createHome(@RequestBody HomePageReq request) {
        return wxMiniHomeClient.createHome(request);

    }

    /**
     * 小程序主页编辑
     * @param request
     * @return
     */
    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑主页")
    @SysMemberLogin
    public Result updateHome(@RequestBody HomePageReq request) {
        return wxMiniHomeClient.updateHome(request);

    }


    /**
     * 小程序主页详情
     * @return
     */
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "主页详情")
    @SysMemberLogin
    public Result<HomePageDetailsVO> homeDetails() {
        return wxMiniHomeClient.homeDetails();
    }




}